package com.feifan.provider.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.feifan.api.model.OmsOrderSetting;
import com.feifan.api.service.IOmsOrderSettingService;
import com.feifan.provider.mapper.OmsOrderSettingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;

/**
 * @program: FinalProject
 * @author: Xiaofan
 * @createTime: 2021-08-09 12:43
 * @description: Functions of this class is
 **/
@Service(
        version ="1.0.0",
        interfaceName = "com.feifan.api.service.IOmsOrderSettingService",
        interfaceClass = IOmsOrderSettingService.class
)
public class OmsOrderSettingService implements IOmsOrderSettingService {

    @Autowired
    private OmsOrderSettingMapper dao;


    @Cacheable(cacheNames = "orderSetting",unless = "#result==null",key = "#id")
    @Override
    public OmsOrderSetting getIntem(Long id) {
        return dao.selectByPrimaryKey(id);//通过主键id去找数据
    }

    @CachePut(cacheNames = "orderSetting",key = "#id")
    @Override
    public OmsOrderSetting update(Long id, OmsOrderSetting omsOrderSetting) {
        omsOrderSetting.setId(id);//先设置主键
        dao.updateByPrimaryKey(omsOrderSetting);//然后通过该对象去设置更新
        return omsOrderSetting;
    }
}